﻿using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using GitNet.WindowsApp.ViewModels;
using LibGit2Sharp;

namespace GitNet.WindowsApp.Views;

public partial class RepositoryView : UserControl
{
    public RepositoryView()
    {
        InitializeComponent();
        //DiffView = this.FindControl<DiffView>("DiffView");
    }

    private void InitializeComponent()
    {
        AvaloniaXamlLoader.Load(this);
    }

    private void ToggleChecked(object? sender, RoutedEventArgs e)
    {
        if (DataContext is not RepositoryViewModel model) return;
        if (sender is not CheckBox control) return;
        if (control.DataContext is not StatusEntry s) return;
        var i = model.StatusFiles.IndexOf(s);
        if (i < 0) return;
        model.SetBooleans((bool)control.IsChecked!, i);
    }
}